    //
//  CourseViewController.m
//  studip
//
//  Created by anti on 05.07.10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CourseOverviewViewController.h"


@implementation CourseOverviewViewController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
/*- (void)loadView {
	NSMutableArray* items = [[NSMutableArray  alloc] init];
	NSMutableArray* sections = [[NSMutableArray  alloc] init];
	
	[sections addObject:@"Wintersemester 2009/2010"];
	
	[items addObject:[TTTableCaptionItem
					  itemWithText: @"Testme"
					  caption: @"Website/Blog"
					  URL: @"fb://course-details"]];
	
	TTSectionedDataSource* ds = [[TTSectionedDataSource alloc] autorelease];
	ds.sections = sections;
	ds.items = items;	
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
/*- (void)viewDidLoad {
  [super viewDidLoad]
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)popToLauncherView
{
  [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)loadView
{
	[super loadView];
  
  [self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"eingangsbildschirm"] style:UIBarButtonItemStyleBordered target:self action:@selector(popToLauncherView)] autorelease] animated:YES];
}

- (id)init {
	if (self = [super init]) {
		self.tableViewStyle = UITableViewStyleGrouped;
		self.variableHeightRows = YES;
		[self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"eingangsbildschirm"] style:UIBarButtonItemStyleBordered target:self action:@selector(popToLauncherView)] autorelease] animated:YES];
		self.title = @"Courses";
		
		NSMutableArray* items = [[NSMutableArray  alloc] init];
		NSMutableArray* sections = [[NSMutableArray  alloc] init];
		NSMutableArray* itemRows = [[NSMutableArray  alloc] init];

		
		[sections addObject:@"Sommersemester 2010"];
		
		[itemRows addObject:[TTTableTextItem
							 itemWithText: @"Designing user experiences"
							 URL: @"fb://courseDetails/1"
							 accessoryURL: @"fb://courseDetails/1"]];
		
		
		[items addObject: itemRows];
		
		TT_RELEASE_SAFELY(itemRows);
		itemRows = [[NSMutableArray  alloc] init];

		
		[sections addObject:@"Wintersemester 2009/2010"];
		
		[itemRows addObject:[TTTableTextItem
							 itemWithText: @"Theoretische Informatik2"
							 URL: @"fb://courseDetails/2"
							 accessoryURL: @"fb://courseDetails/2"]];
		
		
		[items addObject: itemRows];
		TTSectionedDataSource* ds = [[TTSectionedDataSource alloc] autorelease];
		ds.sections = sections;
		ds.items = items;
		self.dataSource = ds;
		
		TT_RELEASE_SAFELY(sections);
		TT_RELEASE_SAFELY(items);
	}
	
	return self;
}

- (void)dealloc {
	[super dealloc];
}


@end
